package com.globalblue;

import java.io.File;
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;

public class DeployManager {
	private static Logger logger = Logger.getLogger(DeployManager.class);

	public void deploy(String source, String destination, List<String> fileList)
			throws Exception {
		for (String fileName : fileList) {

			File srcFile = new File(source + "/" + fileName);
			File destFile = new File(destination + "/" + fileName);
			if (!srcFile.exists()) {
				logger.log(Level.ERROR, "Directory does not exist.");
				System.exit(0);
			} else {

				if (srcFile.isDirectory()) {
					FileUtils.copyDirectory(srcFile, destFile);
				} else {
					FileUtils.copyFile(srcFile, destFile);
				}
				
			}
		}
		FileUtils.deleteDirectory(new File(source));

	}
}
